Skip to content

Win32: Refactor, split off and fix resize logic and DPI changes handling#178

Draft
prokopyl wants to merge 2 commits intoRustAudio:masterfrom
prokopyl:split-win32-resize-logic
Draft

Win32: Refactor, split off and fix resize logic and DPI changes handling#178
prokopyl wants to merge 2 commits intoRustAudio:masterfrom
prokopyl:split-win32-resize-logic

Conversation

@prokopyl
Copy link
Copy Markdown
Member

This PR refactors and splits off the logic that handles re-sizing and discovering/updating the window's DPI.

Some of that logic is split off into a new, low-level Win32Window type, which only handles translating baseview types and assumptions into Win32 calls, separately from managing events or the window handler.

This is part of the effort to split up #174 into smaller pieces.

This PR actually changes the logic, mainly by also splitting the internal window_info into two separate components, current_size (physical) and current_scale_factor, which are instead updated independently during their respective events.

Incidentally, this PR also fixes a few bugs:

  • Fix the window handler not being notified of the new scaling factor that's discovered right after the window is created.
  • Fix a WM_DPICHANGE event triggering a window resize but not triggering a resize event in the window handler. This supersedes the work done in Fix WM_DPICHANGED not triggering Resized event #140.
  • Fix handling of the WM_DPICHANGE event to use the OS-provided window dimensions and position, instead of computing our own dimensions and leaving the position as-is. This avoids a DPI-change loop due to the window constantly switching between two monitors as it's being dragged across them using the mouse.

This has all been tested on my Windows 10 machine and works as expected.

@prokopyl prokopyl requested a review from micahrj March 27, 2024 00:09
@prokopyl prokopyl changed the title Win32; Refactor, split off and fix resize logic and DPI changes handling Win32: Refactor, split off and fix resize logic and DPI changes handling Mar 27, 2024
@prokopyl prokopyl force-pushed the split-win32-resize-logic branch 2 times, most recently from 25e486d to 0188f83 Compare March 29, 2024 23:25
@prokopyl prokopyl force-pushed the split-win32-resize-logic branch from 0188f83 to f512d2a Compare April 6, 2024 15:48
@prokopyl prokopyl marked this pull request as draft May 1, 2026 20:37
@prokopyl
Copy link
Copy Markdown
Member Author

prokopyl commented May 1, 2026

While this is better than #174 was, this is still a bit too large as it has quite a bit of internal refactorings as well. I'll put this back to a draft while I work on a "lite", bugfix-only version of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant